package com.appbee.cm.client.modular.presenter;

import com.appbee.core.client.modular.IModul;
import com.google.web.bindery.event.shared.Event;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;

public class ModulSelectionEvent extends Event<ModulSelectionEvent.Handler>
{

	public interface Handler
	{
		void onChange(ModulSelectionEvent event);
	}

	private static final Type<ModulSelectionEvent.Handler> TYPE = new Type<ModulSelectionEvent.Handler>();

	public static <P> HandlerRegistration register(	EventBus eventBus,
													Object source,
																ModulSelectionEvent.Handler handler)
	{
		return eventBus.addHandlerToSource(TYPE, source, handler);
	}

	private final IModul modul;

	public ModulSelectionEvent(IModul modul)
	{
		this.modul = modul;
	}

	@Override
	public Event.Type<Handler> getAssociatedType()
	{
		return TYPE;
	}

	public IModul getModul()
	{
		return modul;
	}

	@Override
	protected void dispatch(Handler handler)
	{
		handler.onChange(this);
	}
}